﻿/*
#------------------------------------------------------------------------------
#-- Program Name:	[dbo].[spIsDatabaseRestoring]
#-- Purpose:		Is the database in the RESTORING state
#--	Last Update:	04/25/2012
#--					For a complete history - please review comments in Version
#--					control.
#-- Called By:		[dbo].[spRestoreIsAllowed]
#------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[spIsDatabaseRestoring]
(
	@database_name sysname		= NULL
)
AS
BEGIN
	--- If no database name is passed in, set the Database Name to the current database
	IF ISNULL(@database_name, '') = ''
		SELECT	@database_name = DB_NAME()

	--- Return the Answer to the Question
	RETURN	(CASE	WHEN DATABASEPROPERTYEX(@database_name, 'Status') = 'RESTORING'
					THEN 1 ELSE 0 END)
END
